package com.lagou.config;

import com.lagou.interceptor.MyHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: springboot04_blog
 * @description: springmvc拦截器
 * @author: zhoushiduo
 * @create: 2020-12-15 16:02
 */

@Configuration
public class MyAppConf implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(new MyHandlerInterceptor());
        // 拦截所有、排除
        interceptorRegistration.addPathPatterns("/**")
                .excludePathPatterns("/user/login");
    }
}
